/*********************************************************************
*                                                                    *
* This is the Header file for several derivs functions               *
*                                                                    *
*                                                                    *
*********************************************************************/


#include <math.h>
#include "structs_2d.h"    /* place where the used structures are defined */
  
#ifdef DERIVS_2D_H
#else 
#define DERIVS_2D_H


/**********************************************************************
*                                                                     *
* derivS_3d -- take first derivatives of fields using 2-nd order with *
*            no boundary condition, in boundary is only first order   *
*                                                                     *
* Parameters:                                                         *
*       field    -- pointer to field to derivate                      *
*     dfield    -- ptr to field where fst. derivative is stored       *
*                                                                     *
* Returns: nothing                                                    *
*                                                                     *
**********************************************************************/


extern void derivS_2d(struct grid_2d *grid,
		 struct field *field,
		 struct field *dfield,
		 int *coordinate);


/**********************************************************************
*                                                                     *
* lapS_2d -- take laplacion of fields using 2-nd order with           *
*            no boundary condition, in boundary is only first order   *
*                                                                     *
* Parameters:                                                         *
*       field    -- pointer to field to derivate                      *
*     dfield    -- ptr to field where fst. derivative is stored       *
*                                                                     *
* Returns: nothing                                                    *
*                                                                     *
**********************************************************************/


extern void lapS_2d(struct grid_2d *grid,
		 struct field *field,
		 struct field *dfield);

/**********************************************************************
*                                                                     *
* diss_S_2d --  Dissipative second order operator, it is divided      *
*               only by h, so that the coefficient in front should    *
*               not scale with the mesh size                          *
*                                                                     *
* Parameters:                                                         *
*       field    -- pointer to field to derivate                      *
*     dfield    -- ptr to field where fst. derivative is stored       *
*                                                                     *
* Returns: nothing                                                    *
*                                                                     *
**********************************************************************/


extern void diss_S_2d(struct grid_2d *grid,
		 struct field *field,
		 struct field *dfield);


/**********************************************************************
*                                                                     *
* diss_CNG_2d --  Dissipative second order operator, it is divided    *
*               only by h, so that the coefficient in front should    *
*               not scale with the mesh size                          *
*                                                                     *
*               This one is from Carpenter et al                      *
*                                                                     *
* Parameters:                                                         *
*       field    -- pointer to field to derivate                      *
*     dfield    -- ptr to field where fst. derivative is stored       *
*                                                                     *
* Returns: nothing                                                    *
*                                                                     *
**********************************************************************/


extern void diss_CNG_2d(struct grid_2d *grid,
		 struct field *field,
		 struct field *dfield);


/**********************************************************************
*                                                                     *
* diss_S0_2d --  Dissipative second order operator, it is divided     *
*               only by h, so that the coefficient in front should    *
*               not scale with the mesh size                          *
*                                                                     *
*               This one is cero at the last point                    *
*                                                                     *
*                                                                     *
* Parameters:                                                         *
*       field    -- pointer to field to derivate                      *
*     dfield    -- ptr to field where fst. derivative is stored       *
*                                                                     *
* Returns: nothing                                                    *
*                                                                     *
**********************************************************************/


extern void diss_S0_2d(struct grid_2d *grid,
		 struct field *field,
		 struct field *dfield);






/**********************************************************************
*                                                                     *
* derivQ_2d -- take first derivatives of fields using 4-rth order with*
*            no boundary condition, in boundary is only second order  *
*                                                                     *
* Parameters:                                                         *
*       field    -- pointer to field to derivate                      *
*     dfield    -- ptr to field where fst. derivative is stored       *
*                                                                     *
* Returns: nothing                                                    *
*                                                                     *
**********************************************************************/


extern void derivQ_2d(struct grid_2d *grid,
		 struct field *field,
		 struct field *dfield,
		 int *coordinate);


/*********************************************************************
*                                                                    *
* derivQ_3_2d -- take first derivatives of fields using 4-rth order  *
*             with  no boundary condition, in boundary is only       *
*             third order                                            *
*                                                                    *
* Parameters:                                                        *
*       field    -- pointer to field to derivate                     *
*     dfield    -- ptr to field where fst. derivative is stored      *
*                                                                    *
* Returns: nothing                                                   *
*                                                                    *
*********************************************************************/


extern void derivQ_3_2d(struct grid_2d *grid, 
			struct field *field, 
			struct field *dfield, 
			int *coordinate);




/*********************************************************************
*                                                                    *
*  deriv_strand_third_order_boundaries_fourth_interior --            *
*      takes first derivatives of fields with 6-th order accuracy    *
*       in the interior, and third order at and close to boundaries. *
*       This is one of Strand's operator, with diagonal scalar       *
*       product. There are more comments in the function itself      * 
*       in derivs_2d.c                                               *
*                                                                    *
* Parameters:                                                        *
*       field    -- pointer to field to derivate                     *
*     dfield    -- ptr to field where fst. derivative is stored      *
*                                                                    *
* Returns: nothing                                                   *
*                                                                    *
*********************************************************************/


extern void  deriv_strand_third_order_boundaries_sixth_interior_2d(struct GRID_PAR *grid,
					 struct field *field,
					 struct field *dfield,
					 int *coordinate);



/*********************************************************************
*                                                                    *
*  deriv_strand_fourth_order_boundaries_eight_interior --            *
*      takes first derivatives of fields with 8-th order accuracy    *
*       in the interior, and fourth order at and close to boundaries.*
*       This is one of Strand's operator, with diagonal scalar       *
*       product. There are more comments in the function itself      * 
*       in derivs_2d.c                                               *
*                                                                    *
* Parameters:                                                        *
*       field    -- pointer to field to derivate                     *
*     dfield    -- ptr to field where fst. derivative is stored      *
*                                                                    *
* Returns: nothing                                                   *
*                                                                    *
*********************************************************************/

extern void  deriv_strand_fourth_order_boundaries_eight_interior_2d(struct GRID_PAR *grid,
					  struct field *field,
					  struct field *dfield,
					  int *coordinate);




/**********************************************************************
*                                                                     *
* diss_KO4_2d --  Dissipative fourth order operator, it is divided    *
*               only by h, so that the coefficient in front should    *
*               not scale with the mesh size                          *
*                                                                     *
*               This one is cero at the last point                    *
*                                                                     *
*                                                                     *
* Parameters:                                                         *
*       field    -- pointer to field to derivate                      *
*     dfield    -- ptr to field where fst. derivative is stored       *
*                                                                     *
* Returns: nothing                                                    *
*                                                                     *
**********************************************************************/


void diss_KO4_2d(struct GRID_PAR *grid,
		 struct field *field,
		 struct field *dfield);

void diss_KO6_2d(struct GRID_PAR *grid,
		 struct field *field,
		 struct field *dfield);

void diss_KO8_2d(struct GRID_PAR *grid,
		 struct field *field,
		 struct field *dfield);


#endif
